package com.liuhaoqi.raletiveblog.controller;

import com.liuhaoqi.raletiveblog.entity.Test;
import com.liuhaoqi.raletiveblog.entity.dto.CommentsDto;
import com.liuhaoqi.raletiveblog.result.PageResult;
import com.liuhaoqi.raletiveblog.result.WebRestResult;
import com.liuhaoqi.raletiveblog.result.business.PageResult.TestPageResult;
import com.liuhaoqi.raletiveblog.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author liuhaoqi
 * @Date 2020/9/14 18:20
 * @Version 1.0
 */
@RestController
@RequestMapping("TestController")
public class TestController {

    @Autowired
    TestService testService;

    /**
     * 新增评论
     * 如果是顶级评论  parentcommentid 为-1
     * @param test
     * @return
     */
    @PostMapping("addComment")
    public WebRestResult addComment(@RequestBody Test test) {
        WebRestResult result = testService.addComment(test);
        return result;
    }

    /**
     * 得到评论
     * @param blogid
     * @return
     */
    @GetMapping("getCommentList")
    public PageResult<TestPageResult> getCommentList(int blogid) {
        PageResult<TestPageResult> result = testService.getCommentList(blogid);
        return result;
    }
}
